$(function(){
	loadDatas();
	
	//初始化日期控件
  	$('#bt, #et').datetimepicker({
  		language: 'zh-CN',
	    format: 'yyyy-mm-dd hh:00',
	    autoclose: true,
	    minuteStep: 1,
	    minView: "day"
	});
	
	//加载游戏平台下拉数据
	loadGamePlatformForDataCount();
	
});

function findAll(){
	$("#reset").click();
	loadDatas();
}
//查询数据
function loadDatas(){
	//初始化统计图的div
	$("#datMaxOnlineCount").html("").css({color: "",height: "500px", lineHeight: ""});
	
	//加载日最高在线统计图
	loadCountCharts();
	
}

//加载日最高在线统计图
function loadCountCharts(){
	//游戏平台
	var gamePlatform = $("#gamePlatform").val();
	//用户类型
	var userType = $("#userType").val();
	//开始时间
	var begin = $("#begin_time").val();
	//结束时间
	var end = $("#end_time").val();
	$.ajax({
		type:"post",
		data: {"gamePlatform": gamePlatform, "userType": userType, "begin": begin, "end": end},
		url:"../../../php/charts/userOnlineCount/loadAvgAndMaxOnlineCountChart.php",
		beforeSend: function(){
			$("#load").css("display","block");
		},
		success: function(msg){
			$("#load").css("display","none");
			var datas = msg.maxDatas;
			
			if(datas.length == 0){
				$("#datMaxOnlineCount").html("没查询到符合条件的数据~").css({color: "red",height: "100px", lineHeight: "100px"});
			}else{
				//加载曲线图
				Morris.Area({
				    element: 'datMaxOnlineCount',
				    behaveLikeLine: false,
				    gridTextFamily: '微软雅黑',
				    data: datas,
				    xkey: 'x',
				    ykeys: 'y',
				    labels: ['在线'],
				    lineColors:['#6dc5a3'],
				    smooth: true, //幅度效果
				    hideHover: true, //滑鼠移出图表时，提示框是否隐藏
				    parseTime: false,
				    units: '人' //单位
				});
			}
		}
	});
}